import requests

URL = "https://leetcode.cn/graphql/"
payload = {
    "query":
        r'''
        mutation userProfileUpdateProfileV2($data: UpdateProfileInputV2!) {
            userProfileUpdateProfileV2(data: $data) {
                ok
                inReview
            }
         }
        ''',
    "variables":
        r'''{
        "data": {
            "realName": "yingyaoyao🌸",
            "gender": "FEMALE",
            "birthday": "2001-04-07",
            "location": {
                "country": "中国",
                "province": "浙江",
                "city": "杭州"
            },
            "overseasCity": false,
            "aboutMe": "无",
            "websites": [],U
            "github": "",
            "job": "",
            "tags": []
        }
        }
        '''
}
s = 'csrftoken=bfHAQuvZJkXhJqXfFd5pyYjJmg1q5Nzik4d38JtN51LP1lreEBEYmmesjdJNXJDz; gr_user_id=0adaa41d-24e8-4769-9b02-c0d459405a91; p_h5_u=7311FE93-DFB5-476C-AA9A-60E989FAE9D8; selectedStreamLevel=HD; _bl_uid=tvldI94XzX19y7hkt6OUbvRpXIXn; _ga=GA1.1.1106197553.1651816037; _ga_PDVPZYN3CW=GS1.1.1675066603.72.1.1675066895.0.0.0; __atuvc=6%7C3%2C4%7C4%2C7%7C5%2C4%7C6%2C4%7C7; a2873925c34ecbd2_gr_last_sent_cs1=yingyaoyao2; aliyungf_tc=e52103f829e1b12c6dfa90d1e6f06693bd02082c724871a6174536d9eca16762; Hm_lvt_f0faad39bcf8471e3ab3ef70125152c3=1676346447,1676368415,1676464787,1676542646; a2873925c34ecbd2_gr_session_id=bb50490d-788e-4b25-94bb-585d1242f367; a2873925c34ecbd2_gr_last_sent_sid_with_cs1=bb50490d-788e-4b25-94bb-585d1242f367; a2873925c34ecbd2_gr_session_id_bb50490d-788e-4b25-94bb-585d1242f367=true; Hm_lvt_fa218a3ff7179639febdb15e372f411c=1676260648,1676350078,1676469013,1676542697; Hm_lpvt_fa218a3ff7179639febdb15e372f411c=1676542697; LEETCODE_SESSION=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuZXh0X2FmdGVyX29hdXRoIjoiL3Byb2JsZW1zL3R3by1zdW0vIiwiX2F1dGhfdXNlcl9pZCI6IjIwMDg2NTAiLCJfYXV0aF91c2VyX2JhY2tlbmQiOiJkamFuZ28uY29udHJpYi5hdXRoLmJhY2tlbmRzLk1vZGVsQmFja2VuZCIsIl9hdXRoX3VzZXJfaGFzaCI6IjlkYTAyOTVlMzUxYTk2ZGZmNTNiYzZjODQ1MWFjNjM2ZmNlMWU5ZDNlMmEyODJmZWNmYzY3NWJmNjliYTU0MDIiLCJpZCI6MjAwODY1MCwiZW1haWwiOiIyMDgyNTQ3MTIwQHFxLmNvbSIsInVzZXJuYW1lIjoieWluZ3lhb3lhbzIiLCJ1c2VyX3NsdWciOiJ5aW5neWFveWFvMiIsImF2YXRhciI6Imh0dHBzOi8vYXNzZXRzLmxlZXRjb2RlLmNuL2FsaXl1bi1sYy11cGxvYWQvdXNlcnMvZHVzdF8weDdmL2F2YXRhcl8xNjc0OTgwNTA3LnBuZyIsInBob25lX3ZlcmlmaWVkIjpmYWxzZSwiX3RpbWVzdGFtcCI6MTY3NjI3NDM4OS41MTUyNzk4LCJleHBpcmVkX3RpbWVfIjoxNjc4ODIwNDAwLCJ2ZXJzaW9uX2tleV8iOjAsImxhdGVzdF90aW1lc3RhbXBfIjoxNjc2NTQzNDY5fQ.6zrxDtL75-MTTJlMnJzTnijQKmAgjLFUOnF3OcfCwxs; Hm_lpvt_f0faad39bcf8471e3ab3ef70125152c3=1676543470; a2873925c34ecbd2_gr_cs1=yingyaoyao2'

cookies={}#初始化cookies字典变量
for line in s.split(';'):   #按照字符：进行划分读取
    #其设置为1就会把字符串拆分成2份
    name,value=line.strip().split('=',1)
    cookies[name]=value  #为字典cookies添加内容


try:
    resp = requests.post(URL, json=payload.copy(),cookies = cookies,
                         headers = {
                             "referer":"https://leetcode.cn/profile/",
                             'Content-type': 'application/json'
                         }).json()
    print(resp)
except Exception as e:
    print(e)
